I did not enjoy having to debug your code. Part of the problem is that the error handler only works for parser errors, so an error somewhere else causes an error in the error handler.
I did not understand the hard coded "C:\Dxl\dominox.dtd". There is no such file on my system.
I did not understand the Chr$(b) thing. If you are hoping for UTF-8 encoded data, why do you convert everything to the platform character set?